package vip.afeng.rpgclient.app;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import vip.afeng.rpgclient.base.Controller;
import vip.afeng.rpgclient.base.Handle;
import vip.afeng.rpgclient.util.ThreadPool;

import javax.annotation.PostConstruct;
import java.util.Scanner;

/**
 * @datetime: 2020/7/20 20:46
 * @project_name: afeng-rpg
 * @author: afeng
 */
@Component
public class DefaultController implements Controller {

    @PostConstruct
    public void init() {
        ThreadPool.threadPoolExecutor.execute(new Input());
    }


    @Autowired
    @Qualifier("eventHandle")
    private Handle handle;

    class Input implements Runnable{

        @Override
        public void run() {
            while (true) {
                Scanner scanner = new Scanner(System.in);
                String s = scanner.nextLine();
                handle.handle(s);
            }
        }
    }
}
